package com.liezh.adapter;

/**
 * 扩展了TargetAbstraction接口的filter，添加上了本来不兼容的Adaptee的功能
 * @author liezh
 */
public class Adapter extends TargetAbstraction {
    // 持有需要适配的类实例
    private Adaptee adaptee;

    public Adapter() {
        adaptee = new Adaptee();
    }

    /**
     * 扩展代码
     * @param str
     * @return
     */
    public String filter(String str) {
        str = adaptee.preCheck(str);
        return adaptee.replace(str);
    }
}
